<style>
    .btn-group {
        margin-top: 15px;
    }

    .form-group {
        margin-top: 20px;
    }

    .input-group-text {
        margin-top: 15px;
    }

    .custom-select {
        width: 100px;
        height: 30px;
    }
</style>
<script src="/static/ueditor/ueditor.config.js"></script>
<script src="/static/ueditor/ueditor.all.min.js"></script>
<script src="/static/ueditor/lang/zh-cn/zh-cn.js"></script>
<div id="content-container" class="container">
    <div class="row">
        <div class="col-md-3">
            {include file="common/sidenav" /}
        </div>
        <div class="col-md-9">
            <div class="panel panel-default ">
                <div class="panel-body">

                    <table class="table table-bordered">
                        <caption>我的评论</caption>
                        <thead>
                            <tr >
                                <th style="text-align: center;">评论内容</th>
                                <th style="text-align: center;">评论时间</th>
                                <th style="text-align: center;">评论主题</th>
                                <th style="text-align: center;">修改</th>
                                <th style="text-align: center;">删除</th>
                            </tr>
                        </thead>
                        <tbody>
                        {volist name="comment" id="comment"}
                            <tr align="center">
                                <td>
                                    <textarea style="border:none;" id="content{$comment.id}" class="form-control" rows="1">{$comment.content}</textarea>
<!--                                    <input style="border:none;" type="text" class="form-control" id="content" value="{$comment.content}">-->
<!--                                    {$comment.content}-->
                                </td>
                                <td style="width: 160px;">{$comment.createtime|date="Y-m-d H:i",###}</td>
                                <td>{$comment.tie.title}</td>
                                <td><a class="btn btn-primary" href="#" onclick="edit({$comment.id}, {$comment.id})" role="button">修改</a></td>
                                <td><a class="btn btn-primary" href="{:url('index/user/comment_del', array('id' => $comment.id))}" role="button">删除</a></td>
                            </tr>
                        {/volist}
                        </tbody>
                    </table>



                </div>
            </div>
        </div>
    </div>


</div>
<script type="text/javascript">

    function edit(id, cid) {
        var content = $("#content"+cid+"").val()
        $.ajax({
            type: 'post',
            url: "{:url('index/user/updatecomment')}",
            data: {
                id: id,
                content: content
            },
            dataType: 'json',
            success: function (res) {
                if (res.code == 1){
                    console.log(res)
                    layer.msg(res.msg);
                    setTimeout(function () {
                        window.location.reload();
                    }, 1500)
                }else {
                    // console.log(res)
                    setTimeout(function () {
                        window.location.reload();
                    }, 1500)
                    layer.msg(res.msg);
                }

            },
            error: function (res) {
                console.log(res.msg);
            },
        });
    }
</script>